package com.ktjy.actual.service.Impl;

import com.ktjy.actual.entity.Paper;
import com.ktjy.actual.service.PrintService;
import com.ktjy.actual.mapper.PrintMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("printService") //声明这是一个service
public class PrintServiceImpl implements PrintService {

    @Autowired
    @Qualifier("printColoursMapperImpl")
    private PrintMapper printMapper;

    @Override
    public boolean print(Paper paper) {
        //生成0~9的随机数
        int i = (int)(Math.random()*10);

        if(i>=5&&i<7){
            throw new RuntimeException("卡纸异常");
        }
        if (i >= 7 && i <= 9) {
            throw new RuntimeException("墨盒无墨");
        }

        return printMapper.print(paper)>0;
    }
}